/**
 * 
 */
package com.demo2do.wechatmcs.dao;

import java.math.BigInteger;

import com.demo2do.core.persistence.annotation.Condition;
import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.QueryTarget;
import com.demo2do.core.persistence.annotation.Save;
import com.demo2do.core.persistence.annotation.Update;
import com.demo2do.core.persistence.annotation.Variable;
import com.demo2do.wechatmcs.entity.webauth.WechatAccount;

/**
 * @author downpour
 *
 */
@Dao
public interface WechatAccountDao {

    /**
     * 
     * @param wechatAccount
     * @return
     */
    @Save("INSERT INTO wechat_account(create_time, openid, nickname, sex, province, city, country, headimgurl, unionid, language, subscribe_time, remark, groupid) VALUES(:createTime, :openid, :nickname, :sex, :province, :city, :country, :headimgurl, :unionid, :language, :subscribeTime, :remark, :groupid)")
    public BigInteger save(WechatAccount wechatAccount);

    /**
     * 
     * @param openid
     * @return
     */
    @QueryTarget(WechatAccount.class)
    @Condition("WHERE openid = :openid")
    public WechatAccount getWechatAccount(@Variable("openid") String openid);
    
    /**
     * 
     * @param wechatAccount
     */
    @Update("UPDATE wechat_account SET create_time = :createTime, openid = :openid, nickname = :nickname, sex = :sex, province = :province, city = :city, country = :country, headimgurl = :headimgurl, unionid = :unionid, language = :language, subscribe_time = :subscribeTime, remark = :remark, groupid = :groupid WHERE id = :id")
    public void refresh(WechatAccount wechatAccount);
}
